package com.ruoyi.live.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.live.domain.TbWatch;
import com.ruoyi.live.service.ITbWatchService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * guankan jiluController
 * 
 * @author sun
 * @date 2023-01-30
 */
@RestController
@RequestMapping("/watch")
public class TbWatchController extends BaseController
{
    @Autowired
    private ITbWatchService tbWatchService;

    /**
     * 查询guankan jilu列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TbWatch tbWatch)
    {
        startPage();
        List<TbWatch> list = tbWatchService.selectTbWatchList(tbWatch);
        return getDataTable(list);
    }

    /**
     * 导出guankan jilu列表
     */
    @Log(title = "guankan jilu", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbWatch tbWatch)
    {
        List<TbWatch> list = tbWatchService.selectTbWatchList(tbWatch);
        ExcelUtil<TbWatch> util = new ExcelUtil<TbWatch>(TbWatch.class);
        util.exportExcel(response, list, "guankan jilu数据");
    }

    /**
     * 获取guankan jilu详细信息
     */
    @GetMapping(value = "getWatchById/{watchId}")
    public AjaxResult getInfo(@PathVariable("watchId") Integer watchId)
    {
        return success(tbWatchService.selectTbWatchByWatchId(watchId));
    }

    /**
     * 新增guankan jilu
     */
    @Log(title = "guankan jilu", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody TbWatch tbWatch)
    {
        return toAjax(tbWatchService.insertTbWatch(tbWatch));
    }

    /**
     * 修改guankan jilu
     */
    @Log(title = "guankan jilu", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody TbWatch tbWatch)
    {
        return toAjax(tbWatchService.updateTbWatch(tbWatch));
    }

    /**
     * 删除guankan jilu
     */
    @Log(title = "guankan jilu", businessType = BusinessType.DELETE)
	@DeleteMapping("delById/{watchIds}")
    public AjaxResult remove(@PathVariable Integer[] watchIds)
    {
        return toAjax(tbWatchService.deleteTbWatchByWatchIds(watchIds));
    }
}
